Ographe.GraphesView = Ember.View.extend({});

Ographe.Graphe = Ember.Object.extend({
  name: null,
  settingsView: null
});

Ographe.SelectedGrapheController = Ember.Object.create({
  graphe: null
});

var graphes = [
  Ographe.Graphe.create({
    name: 'graphe1'
  }),
  Ographe.Graphe.create({
    name: 'graphe2'
  })
];

graphes.forEach(function (graphe) {
  graphe.set('settingsView', Ember.View.create({
    templateName: graphe.get('name'),
    name: graphe.get('name'),
    didInsertElement: function () {
      var grapheName = graphe.get('name');
      var strFun = "Ographe." + grapheName[0].toUpperCase() + grapheName.substring(1) + "Function";
      var funcCall = strFun + "();";
      var ret = eval(funcCall);
    }
  }));
});

Ographe.GraphesController = Ember.ArrayController.extend({
  content: graphes,
});

Ographe.GrapheView = Ember.ContainerView.extend({
  updateForm: function () {
    var graphe = this.get('graphe');
    if (Ember.isNone(graphe)) return;
    var view = graphe.get('settingsView');
    this.popObject();
    this.pushObject(view);
  }.observes('graphe'),
});